package com.wlc.thread;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 实现Runnable 接口的方式实现多线程
 * @date 2021-07-14 13:57
 */
public class Battle implements Runnable {

    private Hero hero1;
    private Hero hero2;

    public Battle(Hero hero1, Hero hero2) {
        this.hero1 = hero1;
        this.hero2 = hero2;
    }

    @Override
    public void run() {
        while (!hero2.isDead()) {
            hero1.attackHero(hero2);
        }
    }
}
